# database/redis.py
from redis.asyncio import Redis

REDIS_URL = "redis://127.0.0.1:6379/0"

#用户下载次数
USER_DOWNLOAD_COUNT_NAME = "user:count:"

#用户下载时间
USER_DOWNLOAD_TIME_NAME = "user:time:"

redis_pool = None

async def init_redis():
    global redis_pool
    redis_pool = await Redis.from_url(
        REDIS_URL,
        password="test123",
        encoding="utf-8",
        decode_responses=True,
        max_connections=1000,
        socket_keepalive=True
    )
    return redis_pool


async def get_redis() -> Redis:
    return redis_pool